package com.partvoyage.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.shared.HandlerManager;
import com.smartgwt.client.widgets.Canvas;

/**
 * voir http://blog.hivedevelopment.co.uk/2009/08/google-web-toolkit-gwt-mvp-
 * example.html
 */
public class MainModule implements EntryPoint {

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {

		// TODO a remettre pour pouvoir avoir acces aux données calendar
		// oauthService.checkAccess(ClientConstants.AppScope.CALENDAR,
		// new AsyncCallback<User>() {
		// @Override
		// public void onSuccess(User user) {
		// chargerMainLayout(user);
		// }
		//
		// @Override
		// public void onFailure(Throwable caught) {
		// try {
		// throw caught;
		// } catch (NoAccessException naex) {
		// showGrantAccessButton(naex.getRedirectUrl());
		// } catch (Throwable t) {
		// // TODO: handle exception
		// }
		// }
		// });

		AppController appController = new AppController(
				new HandlerManager(null));
		appController.go(new Canvas());
	}
	// private void showGrantAccessButton(final String accessUrl) {
	// System.out.println("showGrantAccessButton():: start");
	// showRedirectButton("Grant access to your calendar", accessUrl);
	// System.out.println("showGrantAccessButton():: exit");
	// }
	//
	// private void showRedirectButton(final String label, final String
	// redirectUrl) {
	// System.out.println("showRedirectButton():: start");
	//
	// Button loginButton = new Button(label);
	// loginButton.setVisible(true);
	// loginButton
	// .addClickHandler(new com.google.gwt.event.dom.client.ClickHandler() {
	//
	// @Override
	// public void onClick(ClickEvent event) {
	// // TODO Auto-generated method stub
	// Window.open(redirectUrl, "", "");
	// }
	// });
	//
	// // add button
	// RootLayoutPanel.get().add(loginButton);
	// System.out.println("showRedirectButton():: exit");
	// }

}
